package crack.three_point_test;

import java.io.IOException;

import crack.AbstractThreePointTestUsingSDAElementDemo;

import math2.MathUtilities;
import fem2.AbstractStructuralCrackDemo;
import fem2.Element;
import fem2.MaterialModel;
import fem2.Mesh;
import fem2.MeshGenerator;
import fem2.MeshPart;
import fem2.Model;
import fem2.element.crack_sda.SKONConstantJumpCSTElement;
import fem2.material.cohesive_law.CohesiveLaw;
import fem2.material.cohesive_law.Mode1ExponentialCohesiveLaw;
import fem2.pre_and_post.GidMeshGenerator;

public class ThreePointTestUsingSKONConstantJumpCSTElementAndExponentialCohesiveLaw extends
		AbstractThreePointTestUsingSDAElementDemo {

	public ThreePointTestUsingSKONConstantJumpCSTElementAndExponentialCohesiveLaw() {
		projectName = "three-point-test2.gid";
		meshFileName = "mesh1-skon";
	}

	@Override
	public Mesh createMesh() {
		String fn = projectDir + '/' + projectName + '/' + meshFileName + ".msh";
		MeshGenerator mg = new GidMeshGenerator(fn);
		Mesh mesh = mg.getMesh(2);
		return mesh;
	}

	@Override
	public CohesiveLaw createCohesiveLaw(Model m) {
		double ft = 2.5;
		double Gf = 0.1;
		double km = -1e5;
		return new Mode1ExponentialCohesiveLaw(Gf, ft, km);
	}

	@Override
	public Element createElement(MeshPart mp, MaterialModel mm, CohesiveLaw cl) {
		Element e = new SKONConstantJumpCSTElement(mp, mm, cl);
		// e.setEchoLevel(EchoLevelType.OUTPUT);
		return e;
	}

	public static void main(String[] args) throws IOException {

		AbstractStructuralCrackDemo sample = new ThreePointTestUsingSKONConstantJumpCSTElementAndExponentialCohesiveLaw();
		// double[] lambda = MyLinAlg.createLambdaArray(0.0307, 0.0001, 0.0309);
		// double[] lambda = MyLinAlg.createLambdaArray(0.0307, 0.0001, 0.04);
		double[] lambda = MathUtilities.createLambdaArray(0.0307, 0.001, 0.3);
		// double[] lambda = MyLinAlg.createLambdaArray(0.0307, 0.001, 0.5); //
		// fail,
		// singular
		// Kgg

		sample.run(lambda);

	}

}
